/*************************************************************************
 *                                                                       *
 * This file is part of the FreeMAPs distribution.  For full copyright   *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:           sqbang                                              *
 * Email:            sqbang@ustc.edu                                     *
 * Date:             2013.11.21                                          *
 *                                                                       *
 *************************************************************************/

//declaration header
#include "COMMON/info/StructuredMeshInfo.h"

//COMMON headers
#include "COMMON/tbox/LogMessage.h"

namespace FreeMAPs
{

StructuredMeshInfo::StructuredMeshInfo(
    const std::string& parent_name,
    const std::string& object_name):
    Parent         (parent_name, object_name),
    d_mesh_package (MeshPackage::SAMRAI)
{}



StructuredMeshInfo::~StructuredMeshInfo()
{
    this->clear();
}



void
StructuredMeshInfo::clear()
{}



void
StructuredMeshInfo::get_from_input (
    const InputDatabase* db)
{
    this->prepare_for_use (db);

    db->insert_allowable_key ("mesh_package");
    db->check_allowable_keys ();

    /*
     * build mesh_package
     */
    {
        if (db->key_exists("mesh_package") && db->is_string("mesh_package"))
        {
            db->check_optional_key ("mesh_package", DataType::STRING, true, false);
            d_mesh_package = db->get_enum_with_default ("mesh_package", d_mesh_package);
        }
    }
}



std::ostream&
operator << (
    std::ostream& os,
    const StructuredMeshInfo& rhs)
{
    os << "structured_mesh_info" << RTN_FLAG;
    os << "{"  << RTN_FLAG;

    os << LogMessage::get_prefix (ONE_TAB) << "mesh_package = \"" << Utilities::enum_to_string (rhs.d_mesh_package) << "\"" << RTN_FLAG;

    os << "}";

    return os;
}

}
